Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert mocha to jest #190

Merged
merged 3 commits into from
Nov 24, 2020
Merged

chore: convert mocha to jest #190

merged 3 commits into from
Nov 24, 2020

Conversation

gagoar
Copy link
Contributor

@gagoar gagoar commented Nov 21, 2020

Description

This PR contains all the changes to make tests run with Jest.

I've removed mocha and chai as well.

Considerations

If this PR is merged we will not need to merge closes #189 🎉

const packageJSON = require('./package.json');

process.env.TZ = 'UTC';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is useful to avoid dealing with dates changing when running under CI systems.

transform: {
'\\.[jt]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left tsx? there because it helps to my next step of moving everything to TS

moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testURL: 'http://localhost',
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
testMatch: ['**/*.(spec|test).js'],
Copy link
Contributor Author

@gagoar gagoar Nov 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used spec as a postfix on the files because IMO is easy to filter tests from other files without looking at the path. Also helps when there's a need for adding other files (ex: helpers) to the test directory without having to filter those in the configuration.

@@ -33,7 +30,7 @@
"start": "node lib/server",
"watch": "babel scripts/watch.js | node",
"test": "npm run lint && npm run check && npm run test:only",
"test:only": "mocha $npm_package_options_mocha",
"test:only": "jest",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally, I would like to name it test but to avoid pilling up too many changes in 1 PR. I've decided to leave if backward compatible.

@acao
Copy link
Member

acao commented Nov 24, 2020

looks fine to me, thanks for this!

@acao acao changed the title From mocha to jest chore: convert mocha to jest Nov 24, 2020
@acao acao merged commit c1ad3d9 into graphql:master Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants